package site.wuao.simpledesignmode.factorymethod.factory;

import site.wuao.simpledesignmode.factorymethod.base.AbstractImageLoader;

/**
 * 具体工厂
 *
 * @author wuao
 * @date 2017/11/5
 * @github {https://github.com/CoderWuao}
 * @blogs {http://wuao.site/}
 * @note -
 * ---------------------------------------------------------------------------------------------------------------------
 * @modified -
 * @date -
 * @github -
 * @blogs -
 * @note -
 */
public class ImageLoaderFactory extends AbstractImageLoaderFactory {
    @Override
    public <T extends AbstractImageLoader> T createImageLoader(Class<T> clazz) {
        AbstractImageLoader abstractImageLoader = null;
        String className = clazz.getName();
        try {
            // 反射生产不同的图片加载器
            abstractImageLoader = (AbstractImageLoader) Class.forName(className).newInstance();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return (T) abstractImageLoader;
    }
}
